home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 177 / pascal / getkey.s < prev    next >
Encoding:
Text File  |  1987-09-16  |  3.5 KB  |  98 lines

  1. *          Intelligent Get_Key function for Personal Pascal
  2. *
  3. *               Written by Keith Ledbetter  6-Sept-87
  4. *          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5.  
  6.  
  7.  
  8.                 .globl  GET_KEY
  9.  
  10.  
  11. gemdos          equ     1
  12. bios            equ     13
  13. xbios           equ     14
  14. kbd             equ     2
  15.  
  16.  
  17.  
  18.  
  19. *       From Pascal:   Function Get_Key: Char;
  20. *       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21.  
  22.  
  23. GET_KEY:        clr.l   d0                      ;so I'm paranoid...
  24.                 move.w  #kbd,-(sp)              ;from keyboard
  25.                 move.w  #2,-(sp)                ;function #2
  26.                 trap    #bios
  27.                 addq.l  #4,sp
  28.  
  29.                 move.l  d0,d1                   ;d0=(shr(d0,8) | (d0 & $ffff)
  30.                 lsr.l   #8,d0
  31.                 and.l   #$ffff,d1
  32.                 or.l    d1,d0
  33.  
  34.  
  35. *       see if this keypress is in the table
  36. *       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37.  
  38.                 move.l  #keytable,a0            ;a0 points to table
  39. lkuploop:       move.w  (a0)+,d1
  40.                 cmp.w   #0,d1                   ;end of table?
  41.                 beq     lk_eot                  ;yep..
  42.                 cmp.w   d0,d1                   ;key match?
  43.                 beq     lk_found                ;yes..
  44.                 addq.l  #2,a0                   ;inc pointer
  45.                 bra     lkuploop                ; and keep cooking..
  46.  
  47. lk_found:       move.w  (a0),d0                 ;return the function key
  48.                 rts                             ; value from the table.
  49.  
  50. lk_eot:         and.w   #$7f,d0                 ;if not in the table, just
  51.                 rts                             ; strip it and return it.
  52.  
  53.                 .even
  54.  
  55. keytable:       dc.w    $3b00,201               ;F1
  56.                 dc.w    $3c00,202               ;F2
  57.                 dc.w    $3d00,203
  58.                 dc.w    $3e00,204
  59.                 dc.w    $3f00,205
  60.                 dc.w    $4000,206
  61.                 dc.w    $4100,207
  62.                 dc.w    $4200,208
  63.                 dc.w    $4300,209
  64.                 dc.w    $4400,210               ;F10
  65.  
  66.                 dc.w    $5400,211               ;F11
  67.                 dc.w    $5500,212
  68.                 dc.w    $5600,213
  69.                 dc.w    $5700,214
  70.                 dc.w    $5800,215
  71.                 dc.w    $5900,216
  72.                 dc.w    $5A00,217
  73.                 dc.w    $5B00,218
  74.                 dc.w    $5C00,219
  75.                 dc.w    $5D00,220               ;F20
  76.  
  77.                 dc.w    $4b00,221               ;left arrow
  78.                 dc.w    $4d00,222               ;right arrow
  79.                 dc.w    $7300,223               ;^left arrow
  80.                 dc.w    $7400,224               ;^right arrow
  81.                 dc.w    $537f,225               ;delete
  82.                 dc.w    $5200,226               ;insert
  83.  
  84.                 dc.w    $6100,227               ;undo
  85.                 dc.w    $6200,228               ;help
  86.                 dc.w    $4700,229               ;clear/home
  87.                 dc.w    $4737,230               ;shift clear/home
  88.                 dc.w    $5230,231               ;shift insert
  89.  
  90.                 dc.w    $4B34,232               ;shift left arrow
  91.                 dc.w    $4838,233               ;shift up arrow
  92.                 dc.w    $4D36,234               ;shift right arrow
  93.                 dc.w    $5032,235               ;shift down arrow
  94.  
  95.                 dc.w    0,0
  96.  
  97.                 .end
  98.